<template>
    <div class="home">
        <img alt="Vue logo" src="../assets/logo.png">
        <input type="text" v-model="someValue">
        <div>{{remoteValue}}</div>
        <button @click="send1">发送</button>
        <button @click="send2">获取</button>
    </div>
</template>

<script>
    // @ is an alias to /src
    import HelloWorld from '@/components/HelloWorld.vue'
    import axios from 'axios';

    export default {
        name: 'Home',
        data() {
            return {
                someValue: '',
                remoteValue: ''
            }
        },
        components: {
            HelloWorld
        },
        methods: {
            send1() {
                axios.defaults.withCredentials = true;
                //第一个请求设置session
                axios.get("http://localhost:8080/testSession1?id=" + this.someValue)
                    .then(resp => {
                        console.log(resp);
                    }).catch(err => {
                    console.log(err);
                })
            },
            send2() {
                axios.defaults.withCredentials = true;
                //第一个请求设置session
                axios.get("http://localhost:8080/testSession2")
                    .then(resp => {
                        console.log(resp);
                        this.remoteValue=resp.data.data;
                    }).catch(err => {
                    console.log(err);
                })
            }
        }
    }
</script>
